<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<h:body>
	<ui:composition template="/template/common/commonLayout.xhtml">

		<ui:define name="content">

			<h:panelGrid>
				<p:dataTable id="trains" var="train"
					value="#{trainTableBean.trainTableDataModel}"
					 scrollable="true"	scrollHeight="300"  style="width: 100%">

					<p:column headerText="Number">  
                   #{train.number}  
                  </p:column>
					<p:column headerText="Seats">  
                   #{train.seats}  
                  </p:column>

					<f:facet name="footer">
						<p:commandButton id="addButton" value="Add"
							icon="ui-icon-circle-plus" oncomplete="addTrainDialog.show()" />
					</f:facet>
				</p:dataTable>
			</h:panelGrid>
			<p:dialog header="Add train" widgetVar="addTrainDialog"
				resizable="false" showEffect="clip" hideEffect="fold">
				<h:panelGrid cellspacing="8">  
			Enter train number: 
			<p:inputText value="#{trainTableBean.number}" />
			Enter train seats: 
			<p:inputText value="#{trainTableBean.seats}" />

					<h:panelGrid columns="2" cellspacing="8">
						<p:commandButton value="Add" onclick="addTrainDialog.hide()"
							action="#{trainTableBean.addTrain()}" update="trains growl" />
						<p:commandButton value="Cancel" onclick="addTrainDialog.hide()" />
					</h:panelGrid>
				</h:panelGrid>
			</p:dialog>
		</ui:define>

	</ui:composition>

</h:body>
</html>